Make Data.List.NonEmpty.toUnfoldable
and Data.List.Lazy.NonEmpty.toUnfoldable
work with Unfoldable1
#220
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description of the change
Modified
toUnfoldable
inData.List.NonEmpty
andData.List.Lazy.NonEmpty
to have the signaturetoUnfoldable :: forall f. Unfoldable1 f => NonEmptyList ~> f
, and reimplemented it accordingly. Additionally added tests covering all fourtoUnfoldable
s, since apparently there were no such tests in the existing codebase.The motivation for this PR is that some users may hypothetically wish to convert known non-empty lists into other structures which cannot be empty. This can be addressed unobtrusively because
Unfoldable1
is a superclass ofUnfoldable
; the old type signature is completely compatible with the new implementation. For lack of a real use case, I was inspired to contribute this change when developing an even more superfluous package of my own which pervasively concerns itself with laziness in unfoldables.Did not bump the version--although I don't think I could have made any breaking changes, I still changed the types of two functions in the public API (and the only relevant tests are ones I wrote), and either way I assume versioning decisions are best left to package maintainers.
Checklist: